const path = require('path');
const fs = require('fs');

module.exports = appInfo => {
    const config = Object({

        name: appInfo.name || 'Ronnie99.live',
        keys: 'ronnie99_19890130lyLY',

        // proxy: false,
        // protocolHeaders: 'x-forwarded-proto',
        // ipHeaders: 'x-forwarded-for',
        // hostHeaders: '',

    }, require('./middleware.js'));

    config.notFound = {
        pageUrl: fs.readFileSync(path.join(appInfo.baseDir, 'app/web/asset/404.html'))
    };

    config.siteFile = {
        '/favicon.ico': fs.readFileSync(path.join(appInfo.baseDir, 'app/web/asset/images/favicon.ico'))
    };

    config.logger = {
        consoleLevel: 'DEBUG',
        dir: path.join(appInfo.baseDir, 'logs')
    };

    config.view = {
        cache: false
    };

    config.vuessr = {
        layout: path.join(appInfo.baseDir, 'app/web/component/layout/template.html'),
        renderOptions: {
            // 告诉 vue-server-renderer 去 app/view 查找异步 chunk 文件
            basedir: path.join(appInfo.baseDir, 'app/view')
        }
    };

    config.seo = require('./seo.js');

    return config;
};
